<?php
namespace App\Http\Controllers\Admin;

use App\Http\Query\NewGoodsQuery;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class NewGoodsController extends Controller
{

    public function NewGoodsPic(Request $request)
    {
        try{
                $NewGoods = new NewGoodsQuery();
                $NewGoodsId = $NewGoods->getGoodsNew();
                for ($x = 0; $x < count($NewGoodsId); $x ++) {
                    if ($NewGoodsId[$x]->category_id == 1) {
                        $goodsId = $NewGoodsId['goods_id'];
                        $NewGoodsRb = $NewGoods->getNewPic($goodsId);
                    }
                    if ($NewGoodsId[$x]->category_id == 2) {
                        $goodsId = $NewGoodsId['goods_id'];
                        $NewGoodsPicRk = $NewGoods->getNewPic($goodsId);
                        return $NewGoodsPicRk;
                    }
                    if ($NewGoodsId[$x]->category_id == 3) {
                        $goodsId = $NewGoodsId['goods_id'];
                        $NewGoodsPicMn = $NewGoods->getNewPic($goodsId);
                        return $NewGoodsPicMn;
                    }
                    if ($NewGoodsId[$x]->category_id == 4) {
                        $goodsId = $NewGoodsId['goods_id'];
                        $NewGoodsPicWr = $NewGoods->getNewPic($goodsId);
                        return $NewGoodsPicWr;
                    }
                }
                foreach ($NewGoodsRb as $NewGoodsPicRb) {
                    return $NewGoodsPicRb;
                }
                foreach ($NewGoodsRk as $NewGoodsPicRk) {
                    return $NewGoodsPicRk;
                }
                foreach ($NewGoodsMn as $NewGoodsPicMn) {
                    return $NewGoodsPicMn;
                }
                foreach ($NewGoodsWr as $NewGoodsPicWr) {
                    return $NewGoodsPicWr;
                }
           }catch (\Exception $e){
            \Log::error($e->getFile()." Line:".$e->getLine()." Msg:".$e->getMessage());
        }
    }
}